package com.suxin.splitter.spliter;

import com.suxin.splitter.ParamSplitter;

import java.util.Collections;
import java.util.List;

/**
 * @author Tang
 * @classname AbstractParamSplitter
 * @description [  ]
 * @date 2022/11/8 13:20
 */
public abstract class AbstractParamSplitter<P> implements ParamSplitter<P> {

    @Override
    public List<P> split(P param, int maxSize) {
        if (param == null) {
            return defaultValue();
        }
        return doSplite(param,maxSize);
    }

    protected abstract List<P> doSplite(P param, int maxSize);

    private List<P> defaultValue() {
        return Collections.emptyList();
    }
}
